/**
 * Projet Multicast Bidois Morgan & Thomas Nunes
 *
 */
package Engine;

import java.nio.ByteBuffer;
import java.util.LinkedList;

/**
 *
 * @author thomas
 *
 * Informations to the functioning of nio engine : the buffers
 * of in and out, a status and a flag
 */
public class InfosNio {

    private NioEngine.StateReceive buffState = NioEngine.StateReceive.READ_LENGTH;
    private Flag flag = new Flag((short) 0);
    private ByteBuffer bufferIn = ByteBuffer.allocate(1000);
    private LinkedList<Message> waitingMessageList = new LinkedList();

    public InfosNio() {
    }

    public NioEngine.StateReceive getBuffState() {
        return buffState;
    }

    public void setBuffState(NioEngine.StateReceive buffState) {
        this.buffState = buffState;
    }

    public Flag getFlag() {
        return flag;
    }

    public void setFlag(Flag flag) {
        this.flag = flag;
    }

    public ByteBuffer getBufferIn() {
        return bufferIn;
    }

    public void setBufferIn(ByteBuffer bufferIn) {
        this.bufferIn = bufferIn;
    }
    /**
     * pop a message to the list (FIFO)
     * 
     * @return Message
     */
    public Message getMessage2send() {
        return (Message) this.waitingMessageList.pop();
    }

    public void addMessage2send(Message message) {
        this.waitingMessageList.add(message);
    }

    boolean isEmptyWaitingList() {
        System.out.println(this.waitingMessageList.isEmpty());
        return this.waitingMessageList.isEmpty();

    }
}
